package et.six.eta.View.ViewPager;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;

import java.util.ArrayList;
import java.util.List;

import et.six.eta.Adapter.EatViewPagerAdapter;
import et.six.eta.R;

public class EatViewPager1 extends RelativeLayout {
    private EatViewPagerAdapter eatViewPagerAdapter;
    private ViewPager mViewPager;
    private List<View> mViewList = new ArrayList<>();
    private int[]mylayouts=new int[]{R.layout.viewpager_view_one,R.layout.viewpager_view_two,R.layout.viewpager_view_three,
            R.layout.viewpager_view_four,};

    public EatViewPager1(Context context) {
        super(context);
        init();
    }
    public EatViewPager1(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {

        inflate(getContext(),R.layout.layout_eat_viewpager,this);
        mViewPager=this.findViewById(R.id.viewpager);
        {
            /**初始化四个界面*/
            for (int i = 0; i < mylayouts.length; i++) {
                View view = View.inflate(getContext(), mylayouts[i], null);
                mViewList.add(view);
            }

        }

        eatViewPagerAdapter=new EatViewPagerAdapter(mViewList,getContext());
        mViewPager.setAdapter(eatViewPagerAdapter);
    }
}
